<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
   <meta name="description" content="string operations">
    
    <meta name="author" content="John S. Urban" >
    <link rel="icon" href="../favicon.png">

    <title>delim &ndash; M_strings</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/pygments.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/local.css" rel="stylesheet">
    
    <link  href="../tipuesearch/tipuesearch.css" rel="stylesheet">
    
    

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="../js/jquery-2.1.3.min.js"></script>
    <script src="../js/svg-pan-zoom.min.js"></script>

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="../index.html">M_strings </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
        
            <li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
              <a href="#" class="dropdown-toggle"
              data-toggle="dropdown" role="button"
              aria-haspopup="true"
     aria-expanded="false">Contents <span class="caret"></span></a>
        <ul class="dropdown-menu">
          
              
            <li><a href="../lists/files.html">Source Files</a></li>
        
        
        
            <li><a href="../lists/modules.html">Modules</a></li>
        
            
                                
            <li><a href="../lists/procedures.html">Procedures</a></li>
        
               
            <li><a href="../lists/types.html">Derived Types</a></li>
        
        
            </ul>
            </li>


<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>

                             
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>


          </ul>
        
        <form action="../search.html" class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
        </div>
<!--
        <button type="submit" class="btn btn-default">Submit</button>
-->
        </form>
        
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
    
  
  <div class="row">
    <h1>delim
      <small>Subroutine</small>
    
    </h1>
    
<div class="row">
  <div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     
     
     
     
    
    
     <li><i class="fa fa-list-ol"></i>
       <a data-toggle="tooltip"
    data-placement="bottom" data-html="true"
    title=" 3.2% of total for procedures.">78 statements</a>
     </li> 
     
     
     
    <li><i class="fa fa-code"></i><a href="../src/M_strings.f90"> Source File</a></li>
     
     
  </ul>
  <ol class="breadcrumb in-well text-right">
  
    
     <li><a href='../sourcefile/m_strings.f90.html'>M_strings.f90</a></li>
    
     <li><a href='../module/m_strings.html'>M_strings</a></li>
    
  
     <li class="active">delim</li>
  </ol>
</div>
</div>
</div>
<script>
  $(function () {
  $('[data-toggle="tooltip"]').tooltip()
  })
</script>

  </div>
  
  <div class="row">
    <div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
    
<div id="sidebar">
  
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-0">Variables</a></h3></div>
  <div id="vars-0" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/delim.html#variable-i10~4">i10</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-iarray">iarray</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-icol">icol</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-idlim">idlim</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-iend~5">iend</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-ifound">ifound</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-istart~2">istart</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-line_local">line_local</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-lstore">lstore</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/delim.html#src">delim</a>
  </div>
</div>



</div>

    </div>
    
    <div class="col-md-9" id='text'>
    <h2>
public subroutine delim(line, array, n, icount, ibegin, iterm, lgth, dlim)
    
    
   
</h2>
    
  


    
    <h2 id="name">NAME</h2>
<div class="codehilite"><pre><span></span><code>  delim(3f) - [M_strings:TOKENS] parse a string and store tokens into
  an array
  (LICENSE:PD)
</code></pre></div>

<h2 id="synopsis">SYNOPSIS</h2>
<div class="codehilite"><pre><span></span><code>subroutine delim(line,array,n,icount,ibegin,iterm,lgth,dlim)

 character(len=*),intent(in)  :: line
 integer,integer(in)          :: n
 integer,intent(out)          :: icount
 character(len=*)             :: array(n)
 integer,intent(out)          :: ibegin(n)
 integer,intent(out)          :: iterm(n)
 integer,intent(out)          :: lgth
 character(len=*)             :: dlim
</code></pre></div>

<h2 id="description">DESCRIPTION</h2>
<div class="codehilite"><pre><span></span><code>  <span class="n">Given</span> <span class="n">a</span> <span class="n">LINE</span> <span class="n">of</span> <span class="n">structure</span> <span class="s2">&quot; par1 par2 par3 ... parn &quot;</span>
  <span class="n">store</span> <span class="n">each</span> <span class="n">par</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> <span class="n">into</span> <span class="n">a</span> <span class="n">separate</span> <span class="n">variable</span> <span class="ow">in</span> <span class="n">ARRAY</span> <span class="p">(</span><span class="n">UNLESS</span>
  <span class="n">ARRAY</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="o">.</span><span class="s1">&#39;#N#&#39;</span><span class="p">)</span>

  <span class="n">Also</span> <span class="n">set</span> <span class="n">ICOUNT</span> <span class="n">to</span> <span class="n">number</span> <span class="n">of</span> <span class="n">elements</span> <span class="n">of</span> <span class="n">array</span> <span class="n">initialized</span><span class="p">,</span> <span class="ow">and</span>
  <span class="k">return</span> <span class="n">beginning</span> <span class="ow">and</span> <span class="n">ending</span> <span class="n">positions</span> <span class="k">for</span> <span class="n">each</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">IBEGIN</span><span class="p">(</span><span class="n">N</span><span class="p">)</span>
  <span class="ow">and</span> <span class="n">ITERM</span><span class="p">(</span><span class="n">N</span><span class="p">)</span><span class="o">.</span>

  <span class="n">Return</span> <span class="n">position</span> <span class="n">of</span> <span class="n">last</span> <span class="n">non</span><span class="o">-</span><span class="n">blank</span> <span class="n">character</span> <span class="p">(</span><span class="n">even</span> <span class="k">if</span> <span class="n">more</span>
  <span class="n">than</span> <span class="n">N</span> <span class="n">elements</span> <span class="n">were</span> <span class="n">found</span><span class="p">)</span> <span class="ow">in</span> <span class="n">lgth</span>

  <span class="n">No</span> <span class="n">quoting</span> <span class="ow">or</span> <span class="n">escaping</span> <span class="n">of</span> <span class="n">delimiter</span> <span class="k">is</span> <span class="n">allowed</span><span class="p">,</span> <span class="n">so</span> <span class="n">the</span> <span class="n">delimiter</span>
  <span class="n">character</span> <span class="n">can</span> <span class="ow">not</span> <span class="n">be</span> <span class="n">placed</span> <span class="ow">in</span> <span class="n">a</span> <span class="n">token</span><span class="o">.</span>

  <span class="n">No</span> <span class="n">checking</span> <span class="k">for</span> <span class="n">more</span> <span class="n">than</span> <span class="n">N</span> <span class="n">parameters</span><span class="p">;</span> <span class="n">If</span> <span class="n">any</span> <span class="n">more</span> <span class="n">they</span> <span class="n">are</span> <span class="n">ignored</span><span class="o">.</span>
</code></pre></div>

<h2 id="options">OPTIONS</h2>
<div class="codehilite"><pre><span></span><code><span class="n">LINE</span>      <span class="n">input</span> <span class="n">string</span> <span class="n">to</span> <span class="n">parse</span> <span class="n">into</span> <span class="n">tokens</span>
<span class="kr">ARRAY</span><span class="p">(</span><span class="n">N</span><span class="p">)</span>  <span class="n">array</span> <span class="n">that</span> <span class="n">receives</span> <span class="n">tokens</span>
<span class="n">N</span>         <span class="n">size</span> <span class="n">of</span> <span class="n">arrays</span> <span class="kr">ARRAY</span><span class="p">,</span> <span class="n">IBEGIN</span><span class="p">,</span> <span class="n">ITERM</span>
<span class="n">ICOUNT</span>    <span class="n">number</span> <span class="n">of</span> <span class="n">tokens</span> <span class="n">found</span>
<span class="n">IBEGIN</span><span class="p">(</span><span class="n">N</span><span class="p">)</span> <span class="n">starting</span> <span class="n">columns</span> <span class="n">of</span> <span class="n">tokens</span> <span class="n">found</span>
<span class="n">ITERM</span><span class="p">(</span><span class="n">N</span><span class="p">)</span>  <span class="n">ending</span> <span class="n">columns</span> <span class="n">of</span> <span class="n">tokens</span> <span class="n">found</span>
<span class="n">LGTH</span>      <span class="n">position</span> <span class="n">of</span> <span class="n">last</span> <span class="n">non</span><span class="o">-</span><span class="n">blank</span> <span class="n">character</span> <span class="n">in</span> <span class="n">input</span> <span class="n">string</span> <span class="n">LINE</span>
<span class="n">DLIM</span>      <span class="n">delimiter</span> <span class="n">characters</span>
</code></pre></div>

<h2 id="examples">EXAMPLES</h2>
<p>Sample program:</p>
<div class="codehilite"><pre><span></span><code> <span class="n">program</span> <span class="n">demo_delim</span>

 <span class="n">use</span> <span class="n">M_strings</span><span class="p">,</span> <span class="n">only</span><span class="p">:</span> <span class="n">delim</span>
 <span class="n">implicit</span> <span class="n">none</span>
 <span class="n">character</span><span class="p">(</span><span class="n">len</span><span class="o">=</span><span class="mi">80</span><span class="p">)</span> <span class="p">::</span> <span class="n">line</span>
 <span class="n">character</span><span class="p">(</span><span class="n">len</span><span class="o">=</span><span class="mi">80</span><span class="p">)</span> <span class="p">::</span> <span class="n">dlm</span>
 <span class="n">integer</span><span class="p">,</span><span class="n">parameter</span> <span class="p">::</span> <span class="n">n</span><span class="o">=</span><span class="mi">10</span>
 <span class="n">character</span><span class="p">(</span><span class="n">len</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span> <span class="p">::</span> <span class="n">array</span><span class="p">(</span><span class="n">n</span><span class="p">)</span><span class="o">=</span><span class="s">&#39; &#39;</span>
 <span class="n">integer</span>           <span class="p">::</span> <span class="n">ibegin</span><span class="p">(</span><span class="n">n</span><span class="p">),</span><span class="n">iterm</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
 <span class="n">integer</span>           <span class="p">::</span> <span class="n">i20</span><span class="p">,</span> <span class="n">icount</span><span class="p">,</span> <span class="n">lgth</span><span class="p">,</span> <span class="n">i10</span>
 <span class="n">line</span><span class="o">=</span><span class="s">&#39; first  second 10.3 words_of_stuff  &#39;</span>
 <span class="n">do</span> <span class="n">i20</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span>
    <span class="err">!</span> <span class="n">change</span> <span class="n">delimiter</span> <span class="n">list</span> <span class="n">and</span> <span class="n">what</span> <span class="n">is</span> <span class="n">calculated</span> <span class="n">or</span> <span class="n">parsed</span>
    <span class="n">if</span><span class="p">(</span><span class="n">i20</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">1</span><span class="p">)</span><span class="n">dlm</span><span class="o">=</span><span class="s">&#39; &#39;</span>
    <span class="n">if</span><span class="p">(</span><span class="n">i20</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">2</span><span class="p">)</span><span class="n">dlm</span><span class="o">=</span><span class="s">&#39;o&#39;</span>
    <span class="n">if</span><span class="p">(</span><span class="n">i20</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">3</span><span class="p">)</span><span class="n">dlm</span><span class="o">=</span><span class="s">&#39; aeiou&#39;</span>    <span class="err">!</span> <span class="n">NOTE</span> <span class="n">SPACE</span> <span class="kr">IS</span> <span class="n">FIRST</span>
    <span class="n">if</span><span class="p">(</span><span class="n">i20</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">3</span><span class="p">)</span><span class="kr">ARRAY</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">=</span><span class="s">&#39;#N#&#39;</span>  <span class="err">!</span> <span class="n">QUIT</span> <span class="n">RETURNING</span> <span class="n">STRING</span> <span class="kr">ARRAY</span>
    <span class="n">if</span><span class="p">(</span><span class="n">i20</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">4</span><span class="p">)</span><span class="n">line</span><span class="o">=</span><span class="s">&#39;AAAaBBBBBBbIIIIIi  J K L&#39;</span>

    <span class="err">!</span> <span class="n">write</span> <span class="n">out</span> <span class="n">a</span> <span class="n">break</span> <span class="n">line</span> <span class="n">composed</span> <span class="n">of</span> <span class="o">===========</span> <span class="p">..</span>
    <span class="n">write</span><span class="cm">(*,&#39;(57(&quot;=&quot;))&#39;)</span>
<span class="cm">    ! show line being parsed</span>
<span class="cm">    write(*,&#39;(a)&#39;)&#39;PARSING=[&#39;//trim(line)//&#39;] on &#39;//trim(dlm)</span>
<span class="cm">    ! call parsing procedure</span>
<span class="cm">    call delim(line,array,n,icount,ibegin,iterm,lgth,dlm)</span>
<span class="cm">    write(*,*)</span><span class="s">&#39;number of tokens found=&#39;</span><span class="p">,</span><span class="n">icount</span>
    <span class="n">write</span><span class="cm">(*,*)</span><span class="s">&#39;last character in column &#39;</span><span class="p">,</span><span class="n">lgth</span>
    <span class="n">if</span><span class="p">(</span><span class="n">icount</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="n">then</span>
       <span class="n">if</span><span class="p">(</span><span class="n">lgth</span><span class="p">.</span><span class="n">ne</span><span class="p">.</span><span class="n">iterm</span><span class="p">(</span><span class="n">icount</span><span class="p">))</span><span class="n">then</span>
          <span class="n">write</span><span class="cm">(*,*)</span><span class="s">&#39;ignored from column &#39;</span><span class="p">,</span><span class="n">iterm</span><span class="p">(</span><span class="n">icount</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; to &#39;</span><span class="p">,</span><span class="n">lgth</span>
       <span class="n">endif</span>
       <span class="n">do</span> <span class="n">i10</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">icount</span>
          <span class="err">!</span> <span class="n">check</span> <span class="n">flag</span> <span class="n">to</span> <span class="n">see</span> <span class="n">if</span> <span class="kr">ARRAY</span><span class="p">()</span> <span class="n">was</span> <span class="n">set</span>
          <span class="n">if</span><span class="p">(</span><span class="n">array</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="n">ne</span><span class="p">.</span><span class="s">&#39;#N#&#39;</span><span class="p">)</span><span class="n">then</span>
             <span class="err">!</span> <span class="n">from</span> <span class="n">returned</span> <span class="n">array</span>
             <span class="n">write</span><span class="cm">(*,&#39;(a,a,a)&#39;,advance=&#39;no&#39;)&amp;</span>
<span class="cm">             &amp;&#39;[&#39;,array(i10)(:iterm(i10)-ibegin(i10)+1),&#39;]&#39;</span>
<span class="cm">          endif</span>
<span class="cm">       enddo</span>
<span class="cm">       ! using start and end positions in IBEGIN() and ITERM()</span>
<span class="cm">       write(*,*)</span>
       <span class="n">do</span> <span class="n">i10</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">icount</span>
          <span class="err">!</span> <span class="n">from</span> <span class="n">positions</span> <span class="n">in</span> <span class="n">original</span> <span class="n">line</span>
          <span class="n">write</span><span class="cm">(*,&#39;(a,a,a)&#39;,advance=&#39;no&#39;)&amp;</span>
<span class="cm">          &amp;&#39;[&#39;,line(ibegin(i10):iterm(i10)),&#39;]&#39;</span>
<span class="cm">       enddo</span>
<span class="cm">       write(*,*)</span>
    <span class="n">endif</span>
 <span class="n">enddo</span>
 <span class="n">end</span> <span class="n">program</span> <span class="n">demo_delim</span>
</code></pre></div>

<p>Expected output</p>
<h2 id="author">AUTHOR</h2>
<div class="codehilite"><pre><span></span><code>John S. Urban
</code></pre></div>

<h2 id="license">LICENSE</h2>
<div class="codehilite"><pre><span></span><code>Public Domain
</code></pre></div>
    

    <h3>Arguments</h3>
    
      
<table class="table table-striped varlist">
<thead><tr><th>Type</th>
<th>Intent</th><th>Optional</th>
<th>Attributes</th><th></th><th>Name</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-line~8"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>line</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-array~2"></span>character(len=*)</td>
  <td></td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>array</strong>(n)</td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-n~2"></span>integer,</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>n</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-icount~3"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>icount</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ibegin~3"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>ibegin</strong>(n)</td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iterm"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>iterm</strong>(n)</td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-lgth~7"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>lgth</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-dlim"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>dlim</strong></td><td></td>
  
</tr>

</tbody>
</table>

    
    
    
    
     
    <br>

    <section class="visible-xs visible-sm hidden-md">
      
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-1">Variables</a></h3></div>
  <div id="vars-1" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/delim.html#variable-i10~4">i10</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-iarray">iarray</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-icol">icol</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-idlim">idlim</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-iend~5">iend</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-ifound">ifound</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-istart~2">istart</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-line_local">line_local</a>
      
      <a class="list-group-item" href="../proc/delim.html#variable-lstore">lstore</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/delim.html#src">delim</a>
  </div>
</div>



    </section>
    <br class="visible-xs visible-sm hidden-md">

    

    
    <section>    
      <h2>Variables</h2>
    
<table class="table table-striped varlist">
<thead><tr><th>Type</th><th>Visibility</th>

<th>Attributes</th><th></th><th>Name</th><th></th><th>Initial</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i10~4"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i10</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iarray"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>iarray</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-icol"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>icol</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-idlim"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>idlim</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iend~5"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>iend</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ifound"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ifound</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-istart~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>istart</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-line_local"></span>character(len=len(line)),</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>line_local</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-lstore"></span>logical,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>lstore</strong></td><td></td><td></td><td></td>
  
</tr>

</tbody>
</table>

    </section>
    <br>
    
    
    
    
    

    
    
    
    
    


    
    
    
    <section>
    <h2><span class="anchor" id="src"></span>Source Code</h2>
    <div class="highlight"><pre><span></span><span class="k">subroutine </span><span class="n">delim</span><span class="p">(</span><span class="n">line</span><span class="p">,</span><span class="k">array</span><span class="p">,</span><span class="n">n</span><span class="p">,</span><span class="n">icount</span><span class="p">,</span><span class="n">ibegin</span><span class="p">,</span><span class="n">iterm</span><span class="p">,</span><span class="n">lgth</span><span class="p">,</span><span class="n">dlim</span><span class="p">)</span>

<span class="c">! ident_10=&quot;@(#)M_strings::delim(3f): parse a string and store tokens into an array&quot;</span>

<span class="c">!</span>
<span class="c">!     given a line of structure &quot; par1 par2 par3 ... parn &quot;</span>
<span class="c">!     store each par(n) into a separate variable in array.</span>
<span class="c">!</span>
<span class="c">!     IF ARRAY(1) == &#39;#N#&#39; do not store into string array  (KLUDGE))</span>
<span class="c">!</span>
<span class="c">!     also count number of elements of array initialized, and</span>
<span class="c">!     return beginning and ending positions for each element.</span>
<span class="c">!     also return position of last non-blank character (even if more</span>
<span class="c">!     than n elements were found).</span>
<span class="c">!</span>
<span class="c">!     no quoting of delimiter is allowed</span>
<span class="c">!     no checking for more than n parameters, if any more they are ignored</span>
<span class="c">!</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>    <span class="kd">::</span> <span class="n">line</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>             <span class="kd">::</span> <span class="n">n</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">)</span>               <span class="kd">::</span> <span class="k">array</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>            <span class="kd">::</span> <span class="n">icount</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>            <span class="kd">::</span> <span class="n">ibegin</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>            <span class="kd">::</span> <span class="n">iterm</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>            <span class="kd">::</span> <span class="n">lgth</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>    <span class="kd">::</span> <span class="n">dlim</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">line</span><span class="p">))</span><span class="kd">::</span> <span class="n">line_local</span>
<span class="kt">logical</span>             <span class="kd">::</span> <span class="n">lstore</span>
<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">i10</span>
<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">iarray</span>
<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">icol</span>
<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">idlim</span>
<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">iend</span>
<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">ifound</span>
<span class="kt">integer</span>             <span class="kd">::</span> <span class="n">istart</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
      <span class="n">icount</span><span class="o">=</span><span class="mi">0</span>
      <span class="n">lgth</span><span class="o">=</span><span class="nb">len_trim</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
      <span class="n">line_local</span><span class="o">=</span><span class="n">line</span>

      <span class="n">idlim</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">dlim</span><span class="p">)</span>
      <span class="k">if</span><span class="p">(</span><span class="n">idlim</span> <span class="o">&gt;</span> <span class="mi">5</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">idlim</span><span class="o">=</span><span class="nb">len_trim</span><span class="p">(</span><span class="n">dlim</span><span class="p">)</span>      <span class="c">! dlim a lot of blanks on some machines if dlim is a big string</span>
         <span class="k">if</span><span class="p">(</span><span class="n">idlim</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span><span class="k">then</span>
<span class="k">            </span><span class="n">idlim</span><span class="o">=</span><span class="mi">1</span>     <span class="c">! blank string</span>
         <span class="k">endif</span>
<span class="k">      endif</span>

<span class="k">      if</span><span class="p">(</span><span class="n">lgth</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span><span class="k">then</span>                                        <span class="c">! command was totally blank</span>
         <span class="k">return</span>
<span class="k">      endif</span>
<span class="c">!</span>
<span class="c">!     there is at least one non-blank character in the command</span>
<span class="c">!     lgth is the column position of the last non-blank character</span>
<span class="c">!     find next non-delimiter</span>
      <span class="n">icol</span><span class="o">=</span><span class="mi">1</span>

      <span class="k">if</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;#N#&#39;</span><span class="p">)</span><span class="k">then</span>                                <span class="c">! special flag to not store into character array</span>
         <span class="n">lstore</span><span class="o">=</span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
      <span class="k">else</span>
<span class="k">         </span><span class="n">lstore</span><span class="o">=</span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
      <span class="k">endif</span>

<span class="k">      do </span><span class="n">iarray</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">n</span><span class="p">,</span><span class="mi">1</span>                                          <span class="c">! store into each array element until done or too many words</span>
         <span class="n">NOINCREMENT</span><span class="p">:</span> <span class="k">do</span>
<span class="k">            if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">dlim</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="n">idlim</span><span class="p">),</span><span class="n">line_local</span><span class="p">(</span><span class="n">icol</span><span class="p">:</span><span class="n">icol</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span><span class="k">then</span>  <span class="c">! if current character is not a delimiter</span>
               <span class="n">istart</span><span class="o">=</span><span class="n">icol</span>                                     <span class="c">! start new token on the non-delimiter character</span>
               <span class="n">ibegin</span><span class="p">(</span><span class="n">iarray</span><span class="p">)</span><span class="o">=</span><span class="n">icol</span>
               <span class="n">iend</span><span class="o">=</span><span class="n">lgth</span><span class="o">-</span><span class="n">istart</span><span class="o">+</span><span class="mi">1</span><span class="o">+</span><span class="mi">1</span>                            <span class="c">! assume no delimiters so put past end of line</span>
               <span class="k">do </span><span class="n">i10</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">idlim</span>
                  <span class="n">ifound</span><span class="o">=</span><span class="nb">index</span><span class="p">(</span><span class="n">line_local</span><span class="p">(</span><span class="n">istart</span><span class="p">:</span><span class="n">lgth</span><span class="p">),</span><span class="n">dlim</span><span class="p">(</span><span class="n">i10</span><span class="p">:</span><span class="n">i10</span><span class="p">))</span>
                  <span class="k">if</span><span class="p">(</span><span class="n">ifound</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span><span class="k">then</span>
<span class="k">                     </span><span class="n">iend</span><span class="o">=</span><span class="nb">min</span><span class="p">(</span><span class="n">iend</span><span class="p">,</span><span class="n">ifound</span><span class="p">)</span>
                  <span class="k">endif</span>
<span class="k">               enddo</span>
<span class="k">               if</span><span class="p">(</span><span class="n">iend</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">)</span><span class="k">then</span>                               <span class="c">! no remaining delimiters</span>
                 <span class="n">iterm</span><span class="p">(</span><span class="n">iarray</span><span class="p">)</span><span class="o">=</span><span class="n">lgth</span>
                 <span class="k">if</span><span class="p">(</span><span class="n">lstore</span><span class="p">)</span><span class="k">then</span>
<span class="k">                    array</span><span class="p">(</span><span class="n">iarray</span><span class="p">)</span><span class="o">=</span><span class="n">line_local</span><span class="p">(</span><span class="n">istart</span><span class="p">:</span><span class="n">lgth</span><span class="p">)</span>
                 <span class="k">endif</span>
<span class="k">                 </span><span class="n">icount</span><span class="o">=</span><span class="n">iarray</span>
                 <span class="k">return</span>
<span class="k">               else</span>
<span class="k">                 </span><span class="n">iend</span><span class="o">=</span><span class="n">iend</span><span class="o">+</span><span class="n">istart</span><span class="o">-</span><span class="mi">2</span>
                 <span class="n">iterm</span><span class="p">(</span><span class="n">iarray</span><span class="p">)</span><span class="o">=</span><span class="n">iend</span>
                 <span class="k">if</span><span class="p">(</span><span class="n">lstore</span><span class="p">)</span><span class="k">then</span>
<span class="k">                    array</span><span class="p">(</span><span class="n">iarray</span><span class="p">)</span><span class="o">=</span><span class="n">line_local</span><span class="p">(</span><span class="n">istart</span><span class="p">:</span><span class="n">iend</span><span class="p">)</span>
                 <span class="k">endif</span>
<span class="k">               endif</span>
<span class="k">               </span><span class="n">icol</span><span class="o">=</span><span class="n">iend</span><span class="o">+</span><span class="mi">2</span>
               <span class="k">exit </span><span class="n">NOINCREMENT</span>
            <span class="k">endif</span>
<span class="k">            </span><span class="n">icol</span><span class="o">=</span><span class="n">icol</span><span class="o">+</span><span class="mi">1</span>
         <span class="k">enddo </span><span class="n">NOINCREMENT</span>
<span class="c">!        last character in line was a delimiter, so no text left</span>
<span class="c">!        (should not happen where blank=delimiter)</span>
         <span class="k">if</span><span class="p">(</span><span class="n">icol</span> <span class="o">&gt;</span> <span class="n">lgth</span><span class="p">)</span><span class="k">then</span>
<span class="k">           </span><span class="n">icount</span><span class="o">=</span><span class="n">iarray</span>
           <span class="k">if</span><span class="p">(</span> <span class="p">(</span><span class="n">iterm</span><span class="p">(</span><span class="n">icount</span><span class="p">)</span><span class="o">-</span><span class="n">ibegin</span><span class="p">(</span><span class="n">icount</span><span class="p">))</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span><span class="k">then</span>         <span class="c">! last token was all delimiters</span>
              <span class="n">icount</span><span class="o">=</span><span class="n">icount</span><span class="o">-</span><span class="mi">1</span>
           <span class="k">endif</span>
<span class="k">           return</span>
<span class="k">         endif</span>
<span class="k">      enddo</span>
<span class="k">      </span><span class="n">icount</span><span class="o">=</span><span class="n">n</span>  <span class="c">! more than n elements</span>
<span class="k">end subroutine </span><span class="n">delim</span>
</pre></div>

    </section>
    <br>
    
    
    </div>
  </div>


    <hr>    
    </div> <!-- /container -->
    <footer>
      <div class="container">
      <div class="row">
        <div class="col-xs-6 col-md-4"><p>&copy; 2022 
                                          </p></div>
        <div class="col-xs-6 col-md-4 col-md-push-4">
          <p class="text-right">
            Documentation generated by 
            <a href="https://github.com/cmacmackin/ford">FORD</a>
             on 2022-01-16 22:32  
          </p>
        </div>
        <div class="col-xs-12 col-md-4 col-md-pull-4"><p class="text-center"> M_strings was developed by John S. Urban</p></div>
      </div>
      <br>
      </div> <!-- /container -->    
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->
    <script src="../js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../js/ie10-viewport-bug-workaround.js"></script>

    <!-- MathJax JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
        jax: ['input/TeX','input/MathML','output/HTML-CSS'],
        extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
      });
    </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    
    <script src="../tipuesearch/tipuesearch_content.js"></script>
    <script src="../tipuesearch/tipuesearch_set.js"></script>
    <script src="../tipuesearch/tipuesearch.js"></script>
    
    
  </body>
</html>